package apk.yoursms;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Toast;
import apk.yoursms.settings.Statistics;

import com.StarsSDK.Utils.Utils;

public class TitleBar extends Activity {

    public void onApps(View v) {
	Statistics.setData("Apps View");
	if (Utils.isOnline()) {
	    try {
		startActivity(new Intent(Intent.ACTION_VIEW,
			Uri.parse("market://search?q=pub:StarsApplications")));
	    } catch (Exception e) {
		Toast.makeText(this, R.string.error, Toast.LENGTH_LONG).show();
	    }
	} else {
	    Toast.makeText(this, R.string.should_connection, Toast.LENGTH_LONG)
		    .show();
	}
    }

    public void onRate(View v) {
	Statistics.setData("Rate");
	SharedPreferences setting = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
	if (Utils.isOnline()) {
	    try {
		Intent intent = new Intent(Intent.ACTION_VIEW);
		intent.setData(Uri.parse("market://details?id=apk.yoursms"));
		startActivity(intent);
		setting.edit().putBoolean("show_rating", true).commit();
	    } catch (Exception e) {
		Toast.makeText(this, R.string.error, Toast.LENGTH_LONG).show();
	    }
	} else {	    
	    Toast.makeText(this, R.string.should_connection, Toast.LENGTH_LONG)
		    .show();
	}
    }

}
